package com.beemans.topon.kts

import com.beemans.topon.data.CustomKeyResponse

/**
 * @author ti
 * @date 2022/11/23.
 */

/**
 * 获取流量分组自定义配置
 */
internal fun convertCustomMap(
    customKeyResponse: CustomKeyResponse?,
    customMap: Map<String, String>?
): MutableMap<String, Any> {
    val newCustomMap = mutableMapOf<String, Any>()
    customKeyResponse.toJson()?.also { str ->
        str.fromJson<Map<String, String>>()?.let {
            newCustomMap.putAll(it)
        }
    }
    if (customMap?.isNotEmpty() == true) {
        newCustomMap.putAll(customMap)
    }
    return newCustomMap
}